package trabalho;

/*
 * Classe para a abertura do arquivo contendo
 * a lista de vertice e arestas.
 */

import java.io.File;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;

public class OpenFile {
	File fileName;
	public OpenFile(){
		   File name;
		   JFileChooser fileChooser = new JFileChooser();
		   fileChooser.setFileSelectionMode(             
		      JFileChooser.FILES_AND_DIRECTORIES );
		   name = fileChooser.getSelectedFile();
		   int result = fileChooser.showOpenDialog(fileChooser);
		   if (result == JFileChooser.CANCEL_OPTION)
			      System.exit( 1 );
		   fileName = fileChooser.getSelectedFile();

		   if ( ( fileName == null ) || ( fileName.getName().equals( "" ) ) ){
		      JOptionPane.showMessageDialog(fileChooser, "Invalid File Name",
		         "Invalid File Name", JOptionPane.ERROR_MESSAGE );
		      System.exit( 1 );
		   }
	}
	public String getPath(){
		return fileName.getPath();
	}
	
}